package com.lc.pianostudent.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/2/22.
 */
@HttpInlet(Conn.MAIL_XINGKA)
public class PostMailXingka extends BaseAsyPost {

    public String num;//星卡数量

    public PostMailXingka(AsyCallBack asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected PostMailXingkaInfo parser(JSONObject object) throws Exception {

        if (object.optString("code").equals("200")) {

            PostMailXingkaInfo info = new PostMailXingkaInfo();


            info.code = object.optString("code");
            JSONArray array = object.optJSONArray("data");
            if(array != null || array.length() != 0){
                for(int i = 0;i<array.length();i++){
                    JSONObject jsonObject = array.optJSONObject(i);
                    info.imgList.add(jsonObject.optString("picurl"));
                }
            }

            TOAST = object.optString("message");

            return info;

        } else {

            TOAST = object.optString("message");

        }

        return null;
    }

    public static class PostMailXingkaInfo {

        public String code;

        public List<String> imgList = new ArrayList<>();
    }
}
